<template>
    <div>
        <a-tabs v-model="tabKey">
            <a-tab-pane key="columnConf" :tab="i18n('columnConf','列头设置')" forceRender>
                <Edit2ColumnConf ref="columnConf" :fieldDataAll="fieldDataAll" :default-value="listConfig.columnConf || {}" />
            </a-tab-pane>
            <a-tab-pane key="tabTreeConf" :tab="i18n('tabTreeConf','导航树配置')" forceRender>
                <Edit2TabTreeConf ref="tabTreeConf" :fieldDataAll="fieldDataAll" :default-value="listConfig.tabTreeConf || {}" />
            </a-tab-pane>
            <a-tab-pane key="searchConf" :tab="i18n('searchConf','搜索条件配置')" forceRender>
                <Edit2SearchConditionConf ref="searchConf" :fieldDataAll="fieldDataAll" :default-value="listConfig.searchConf || {}" />
            </a-tab-pane>
            <a-tab-pane key="searchViewConf" :tab="i18n('searchViewConf','查询视图配置')" forceRender>
                <Edit2SearchViewConf ref="searchViewConf" :fieldDataAll="fieldDataAll" :default-value="listConfig.searchViewConf || {}" />
            </a-tab-pane>
            <a-tab-pane key="toolBarConf" :tab="i18n('toolBarConf','功能按钮')" forceRender>
                <Edit2ToolBar ref="toolBarConf" :fieldDataAll="fieldDataAll" :formData="formData" :default-value="listConfig.toolBarConf || {}" />
            </a-tab-pane>
            <a-tab-pane key="funConf" :tab="i18n('funConf','PC端JS函数')" forceRender>
                <Edit2PCFunctionForJS ref="funConf" :default-value="listConfig.funConf || {}" />
            </a-tab-pane>
        </a-tabs>
    </div>
</template>

<script>
import FormCodegenBusinessEdit2 from './FormCodegenBusinessEdit2.js'
import rxInputIcon from '@/components/rxComponent/rx-input-icon'
import Edit2ColumnConf from './components/Edit2ColumnConf'
import Edit2TabTreeConf from './components/Edit2TabTreeConf'
import Edit2ToolBar from './components/Edit2ToolBar'
import Edit2SearchConditionConf from './components/Edit2SearchConditionConf'
import Edit2SearchViewConf from "./components/Edit2SearchViewConf";
import Edit2PCFunctionForJS from './components/Edit2PCFunctionForJS'
import { BaseForm, RxLayout, RxGrid, RxSelect } from "@lowcode/jpaas-common-lib"

export default {
    name: 'FormCodegenBusinessEdit2',
    components: {
        RxLayout,
        RxGrid,
        RxSelect,
        rxInputIcon,
        Edit2ColumnConf,
        Edit2TabTreeConf,
        Edit2ToolBar,
        Edit2SearchConditionConf,
        Edit2SearchViewConf,
        Edit2PCFunctionForJS,
    },
    mixins: [BaseForm, FormCodegenBusinessEdit2],
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"formCodegenBusiness.edit2",key);
        },
        handleSubmit(self, _this, callback) {
            for(let i=0;i<_this.tabList.length;i++){
                let tabKey=_this.tabList[i];
                const result=_this.$refs[tabKey].collectData();
                if(!result.success){
                    _this.tabKey=tabKey;
                    _this.$message.warning(result.message);
                    return callback(true);
                }
                _this.listConfig[tabKey]=result.data;
            }
            _this.settingJson.listConfig = _this.listConfig;
            _this.formData.settingJson = JSON.stringify(_this.settingJson);
            _this.$emit('changeForm', _this.formData)
            callback()
        },
    },
}
</script>

<style scoped></style>
